<?php
chdir("source" . DIRECTORY_SEPARATOR . ".Pictet2");
$test = new RecursiveDirectoryIterator(".");

$index = file_get_contents("../index.php");

$contents = "";
foreach(new RecursiveIteratorIterator($test) as $file) {
	
	$info = pathinfo($file);
	if($info["extension"] == "php") {
		print $file . "\n";
		$contents .= "/*\n * " . $file . "\n */\n\n" . preg_replace("/<\?php/", "", file_get_contents($file)) . "\n\n";
	}
}

$output = preg_replace("/###COMPILEBLOCK###/", $contents, $index);
$output = preg_replace("/###COMPILEDATE###/", date('r'), $output);
file_put_contents("../../" . "index" . ".php", $output);